<template>
  <div class="newsinfo-container">
    <h3 class="title">{{newsInfo.title}}</h3>
    <p class="subtitle">
      <span>发表时间{{newsInfo.add_time|timeFormat}}</span>
      <span>点击{{newsInfo.click}}次</span>
    </p>
    <hr>
    <div class="content" v-html="newsInfo.content"></div>

    <!-- 发表评论区域 -->
    <comment :id="id"></comment>
  </div>
</template>
<script>
import comment from '../subcompents/comment.vue'
export default {
  data() {
    return {
      id: this.$route.params.id,
      newsInfo:{}
    };
  },
  methods: {
      getNewsInfo(){
          this.$http.get('api/getnew/'+this.id).then(function (res) {
              if(res.body.status==0){
                  this.newsInfo=res.body.message[0]

              }
            })
      }
  },
  created() {
      this.getNewsInfo()
  },
  components:{
    comment
  }
};
</script>   
<style lang="scss" scoped>
.newsinfo-container{
    padding: 0 5px;
    overflow: hidden;
    .title{font-size: 16px;text-align: center;color: red;margin: 10px 0;}
    .subtitle{display: flex;justify-content: space-between}
    .content{font-size: 12px}

}
</style>
